﻿using System.Collections.Generic;

namespace DomainModel
{
    public class Subject : BaseEntity
    {
        private const int AUTO_SHORT_NAME = 15;

        protected Subject() { }

        public Subject(string name)
            : this()
        {
            Name = name;
            ShortName = AutoShortName(name);
        }

        public Subject(string name, string shortName)
            : this()
        {
            Name = name;
            ShortName = AutoShortName(shortName);
        }

        public virtual string Name { get; set; }
        public virtual string ShortName { get; set; }

        private string AutoShortName(string name)
        {
            if (name.Length <= AUTO_SHORT_NAME)
            {
                return name;
            }
            
            return name.Substring(0, AUTO_SHORT_NAME);
        }
    }
}
